const express = require("express")
const app = express()
const router = require('./router')
const bodyParser = require('body-parser')

// 自定义中间件，设置跨域需要的响应头。
const allowCrossDomain = function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  next();
};

app.use(allowCrossDomain);

app.use(bodyParser.urlencoded({ extended: false }))
app.use('/',router)



//启动http服务 
const server = app.listen(3000, function () {
  var host = server.address().address;
  var port = server.address().port;
});